//无重复字符的最长子串
class code1 {
    public int lengthOfLongestSubstring(String s) {
        int left = 0;
        int right = 0;
        int ret = 0;
        int[] hash = new int[128];

        while(right < s.length()) {
            //进窗口
            hash[s.charAt(right)]++;

            //判断
            while(hash[s.charAt(right)] > 1) {
                //出窗口
                hash[s.charAt(left++)]--;
            }

            //更新结果
            ret = Math.max(ret,right-left+1);
            right++;
        }
        return ret;
    }
}